package com.ease.integration.jms.listener;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

public abstract class StringMessageListener implements MessageListener {

	public abstract void onMessage(String text);

	public void onMessage(Message message) {
		if (message instanceof TextMessage) {
			TextMessage textMessage = (TextMessage) message;
			String text = null;
			try {
				text = textMessage.getText();
			} catch (JMSException e) {
				// TODO log
				e.printStackTrace();
			}
			System.out.println(" :" + text);
			this.onMessage(text);
		} else {
			// TODO throw new NestedRuntimeException
		}
	}

}
